package pers.cz.orm.lesson1;

import pers.cz.easyexcel.dao.CommonLocalFileDaoImpl;
import pers.cz.orm.dao.CommonDbDaoImpl;
import pers.cz.orm.lesson1.entity.InsSystem;

import java.io.File;
import java.util.List;

/**
 * @program: Jef-orm
 * @description: 案例1
 * @author: Cheng Zhi
 * @create: 2023-11-26 15:53
 **/
public class Case1 {


    public static void main(String[] args) {
        Case1 case1 = new Case1();
        case1.testSelectAndInsertExcel();
    }

    /**
     * @author Chengzhi
     * @date 2023-11-26
     * @测试目的： 从数据库中查询到数据并且将数据转储到excel中
     * @预期结果:
     */
    public void testSelectAndInsertExcel(){
        InsSystem insSystem = new InsSystem();
        List<InsSystem> list = new CommonDbDaoImpl().find(insSystem);
        new CommonLocalFileDaoImpl(new File("D:\\test\\test-V1-20231126.xlsx")).batchInsert(list);
    }

    /**
     * @author Chengzhi
     * @date 2023-11-26
     * @测试目的： 测试实体中带有int类型的excel插入
     * @预期结果:
     */
    public void testInertExcelWithInt(){

        InsSystem insSystem = new InsSystem();
        insSystem.setSysId(3);
        new CommonLocalFileDaoImpl(new File("D:\\test\\test-V1-20231126.xlsx")).insert(insSystem);
    }
}
